using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace SmartLink.Infrastructure
{
    /// <summary>
    /// 安全加密
    /// </summary>
    public class SecurityHelper
    {
        /// <summary>
        /// MD5加密方法
        /// </summary>
        /// <returns></returns>
        public static string ToMd5(string pwd)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            var fromData = System.Text.Encoding.Unicode.GetBytes(pwd);
            var targetData = md5.ComputeHash(fromData);
            var byte2String = new StringBuilder();
            foreach (var t in targetData)
            {
                byte2String.Append(t.ToString("X2"));
            }
            return byte2String.ToString();
        }
    }
}
